import { defineConfig } from 'vite'
import reactRefresh from '@vitejs/plugin-react-refresh'

// https://vitejs.dev/config/
export default defineConfig({
  build: {
    target: 'es2015',
    rollupOptions: {
      output: {
        manualChunks(id) {
          console.log(id);
          if (/node_modules\/.*(antd|ant-design)/.test(id)) {
            return 'ui-chunk';
          }
          if (/node_modules\/.*(axios|moment)/.test(id)) {
            return 'plugin-chunk';
          }
          if (/node_modules\/.*(react|mobx)/.test(id)) {
            return 'react-chunk';
          }
          if (id.includes('node_modules')) {
            return 'vendor';
          }
        }
      }
    }

  },
  plugins: [reactRefresh()]
})
